package com.cloudz.iptv.fragment.content.v1.adapter;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.alibaba.android.vlayout.DelegateAdapter;
import com.alibaba.android.vlayout.LayoutHelper;
import com.cloudz.iptv.R;
import com.cloudz.iptv.fragment.content.v1.adapter.data.ItemImageTextBean;

import java.util.List;

public class GridHelperAdapter extends DelegateAdapter.Adapter<RecyclerView.ViewHolder>
{

    private LayoutHelper layoutHelper;

    private List<ItemImageTextBean> datas;

    public GridHelperAdapter(List<ItemImageTextBean> datas, LayoutHelper layoutHelper)
    {
        this.datas = datas;
        this.layoutHelper = layoutHelper;
    }

    @NonNull
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i)
    {
        View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_grid_text_image_layout, viewGroup, false);
        return new RecyclerViewItemHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int i)
    {

    }

    @Override
    public int getItemCount()
    {
        return datas.size();
    }

    @Override
    public LayoutHelper onCreateLayoutHelper()
    {
        return layoutHelper;
    }


    /**
     * 正常条目的item的ViewHolder
     */
    private class RecyclerViewItemHolder extends RecyclerView.ViewHolder {

        public ImageView iv_icon;

        public TextView title;

        public RecyclerViewItemHolder(View itemView) {
            super(itemView);
            this.iv_icon = itemView.findViewById(R.id.image);
            this.title = itemView.findViewById(R.id.title);
        }
    }
}
